m,n=map(int,input().split())
times=list(map(int,input().split()))

def getResult():
    times.sort()
    mArr=[0]*m
    for i in range(0,len(times)):
        mArr[i%m]=mArr[i%m]+times[i]
    return max(mArr)
print(getResult())